// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
// http://www.zhengzhong.net/
//
// $Id: base.cpp 318 2009-03-02 14:03:21Z heavyzheng $
//

#ifndef ZZHENG_XML_SOURCE
#define ZZHENG_XML_SOURCE
#endif // ZZHENG_XML_SOURCE

#include <zzheng/xml/sax/libxml2/base.hpp>
#include <libxml/tree.h>
#include <cassert>

namespace zzheng {
namespace xml {
namespace sax {
namespace libxml2_ {

    globals::globals() {
        LIBXML_TEST_VERSION;  // check libxml2 version.
        xmlInitParser();      // initialize parser (necessary for thread safety).
        // xmlSubstituteEntitiesDefault(1);  // libxslt init
        // xmlLoadExtDtdDefaultValue = 1;    // libxslt init
    }

    globals::~globals() {
        try {
            // xsltCleanupGlobals();
            xmlCleanupParser();
        } catch (...) {
            // ignore all errors to make destructor exception-free.
        }
    }

    base::base() {
        // Call the instance function to make sure the globals singleton instance is created.
        // We don't need the singleton instance, so we don't care about the return value.
        globals::instance();
    }

} // namespace zzheng::xml::sax::libxml2_
} // namespace zzheng::xml::sax
} // namespace zzheng::xml
} // namespace zzheng



